<?php

namespace Biz\service\springHomeDecActivity;

use Biz\pockets\constInterface\SpringHomeDecConfig;

class ActivityService implements SpringHomeDecConfig
{
    /**
     * 获取活动信息
     * @return array
     */
    public static function activityInfo()
    {
        $lastDay = date('Y-m-d') == self::ACTIVITY_LAST_DAY ? true : false;
        $isStart = time() >= strtotime(self::ACTIVITY_TIME_START) && time() < strtotime(self::ACTIVITY_TIME_END);
        $isEnd = time() > strtotime(self::ACTIVITY_TIME_END);
        $isLuckyCharmPublish = time() > strtotime(self::ACTIVITY_LUCKY_CHARM_PUBLISH_TIME);
        $activityTime = [
            'begin_time' => self::ACTIVITY_TIME_START,
            'end_time' => self::ACTIVITY_TIME_END,
            'lucky_charm_publish_time' => self::ACTIVITY_LUCKY_CHARM_PUBLISH_TIME,
            'last_day' => self::ACTIVITY_LAST_DAY,
            'is_last_day' => $lastDay,
            'is_activity_end' => $isEnd,
            'is_activity_start' => $isStart,
            'is_lucky_charm_publish' => $isLuckyCharmPublish,
        ];
        return $activityTime;
    }

    /**
     * 是否进行
     * @return bool
     */
    public static function running()
    {
        $activityInfo = self::activityInfo();
        if (!$activityInfo['is_activity_end'] && !$activityInfo['is_lucky_charm_publish']) {
            return true;
        }
        return false;
    }


}